###
# Copyright (C) 2010 Razvan Constantin <razvan.constantin@rconst.net>
#
# This file is part of FileBow.
#
# FileBow is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FileBow is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FileBow.  If not, see <http:#www.gnu.org/licenses/>.
###

# Main build script for Geany FileBow Plugin.
#
# To build and install Geany FileBow plugin run:
#   ./waf configure
#   ./waf build
#   ./waf build --test # Builds and run unittests
#   sudo ./waf install
#
# Additional configuration options:
#   --geany-includes[=/usr/local/include/geany] prefix location for geany includes
#   --geany-plugins[=/usr/local/lib/geany] plugins base
#
# Unit tests can be build and executed using:
#   ./waf build --test

APPNAME = 'FileBow'
VERSION = '0.1'

srcdir = '.'
blddir = 'build'

### Imports

import Options
import Utils

import crun
import builder
import configurator

### Build specification

def set_options(opt):
  opt.tool_options('compiler_cxx compiler_cc')
  opt.add_option('--cfg-tool', default='pkg-config',
                 help='Alternative tool/path for pkg-config (gtk discovery)',
                 action='store', dest='cfg_tool', type='string')
  opt.add_option('--geany-includes', default='/usr/local/include/geany',
                 help='Geany include directory',
                 action='store', dest='geany_includes', type='string')
  opt.add_option('--geany-plugins', default='/usr/local/lib/geany',
                 help='Geany plugin directory',
                 action='store', dest='geany_plugins', type='string')
  opt.add_option('--test', default=False, action='store_true')

def configure(conf):
  conf.check_tool('compiler_cxx compiler_cc')
  conf.env['CXXFLAGS'] = [ '-fPIC' ]
  conf.env['CCFLAGS'] = [ '-fPIC' ]
  conf.env['CFG_TOOL'] = Options.options.cfg_tool
  conf.env['GEANY_INCLUDES'] = Options.options.geany_includes
  conf.env['GEANY_PLUGINS'] = Options.options.geany_plugins
  configurator.extend(conf)
  conf.configure_poco()
  conf.configure_gtest()
  conf.recurse('common logic testing ui utils')

def build(bld):
  builder.extend(bld)
  bld.recurse('common logic testing ui utils')
  bld.build_plugin('filebow',
      'ui/filebow.cpp',
      deps = ('ui#plugin', 'ui#geany-bridge',))

def shutdown():
  pass
